{{ include('/include/head.html') }}

<style>

  p{
    margin-bottom:0px;
  }
</style>

<div class="container">

  
  <div class="alert alert-dismissible alert-success mt-5"  id="success" hidden>
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <p></p>
  </div>

  <div class="alert alert-dismissible alert-danger mt-5 hide" id="error" hidden>
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <p></p>
  </div>

<div class="row  mt-5 mb-5">
    <div class="col-lg-12">
      <div class="page-header">
        <h2>新增角色</h2>
      </div>
      <button type="button" class="btn btn-success mt-3" onclick="location.href='/admin/user_group'">返回</button>
    </div>
  </div>
  <form id="formdata">
    <fieldset>
      <legend>创建权限的用户组</legend>
      
      <div class="form-group mt-3">
        <input type="text" class="form-control"  placeholder="用户组名称" name="title">
      </div>
        <div class="form-group">
          <select class="form-control" name="status">
            <option value="1">正常使用</option>
            <option value="2">禁用</option>
          </select>
        </div>
      <button type="button" class="btn btn-danger mt-3" id="submit">提交</button>
    </fieldset>
  </form>
  
  <script src="{{ PUBLIC_ADMIN }}/js/jquery.min.js"></script>
  <script src="{{ PUBLIC_ADMIN }}/js/popper.min.js"></script>
  <script src="{{ PUBLIC_ADMIN }}/js/bootstrap.min.js"></script>
  

  <script>
    // alert($('#formdata').serialize());

    

    $(function(){  
       
         'use strict';
         
          $("#submit").click(function(){
             
            Exe();

          });

     

    

    function Exe(){  
        $.ajax({
              //提交数据的类型 POST GET
              type:"POST",
              //提交的网址
              url:"/admin/user_group_post",
              //提交的数据
              data:$('#formdata').serialize(),
              //返回数据的格式
              datatype: "json",//"xml", "html", "script", "json", "jsonp", "text".
              //在请求之前调用的函数
              // beforeSend:function(){$("#msg").html("logining");},
              //成功返回之后调用的函数             
              success:function(data){
                   $("#error").fadeIn().removeAttr("hidden");
                   $('#error>p').text(data);     
              },
              //调用出错执行的函数
              error: function(){
                  alert("请求异常");
                  exit();
              }         
          });
    }
    });
  
    </script>

{{ include('include/footer.html') }}